package com.oracle.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogProxy {
	
	@Pointcut(value="execution(* com.oracle.dao..*.*(..))")
	public void log(){}
	
	@Before("log()")
	public void logStart(){
		System.out.println("Log start ......");
	}
	@AfterReturning("log()")
	public void logReturn(){
		System.out.println("Log return......");
	}
	@AfterThrowing("log()")
	public void logException(){
		System.out.println("Log exception......");
	}
	@After("log()")
	public void logEnd(){
		System.out.println("Log end ......");
	}
	@Around("log()")
	public void logAround(ProceedingJoinPoint pjp){
		System.out.println("Log around befor");
		try {
			pjp.proceed();
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("Log around after");
	}
}
